package com.chen.shopping_admin_service.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chen.shopping_admin_service.mapper.AdminMapper;
import com.chen.shopping_admin_service.mapper.PermissionMapper;
import com.chen.shopping_common.pojo.Admin;
import com.chen.shopping_common.pojo.Permission;
import com.chen.shopping_common.service.PermissionService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public void addPermission(Permission permission) {
        permissionMapper.insert(permission);
    }

    @Override
    public void updatePermission(Permission permission) {
        permissionMapper.updateById(permission);
    }

    @Override
    public void deletePermission(Long pid) {
        permissionMapper.deleteById(pid);
        permissionMapper.deletePermission(pid);
    }

    @Override
    public Permission findPermissionById(Long pid) {
        return permissionMapper.selectById(pid);
    }

    @Override
    public List<Permission> findPermissionAll() {
        return permissionMapper.selectList(null);
    }

    @Override
    public Page<Permission> findPermissionByPage(int page, int size) {
        return permissionMapper.selectPage(new Page<>(page,size),null);
    }


}
